<?php
/**
 * WxYun Yii Upload Helper
 * 
 * @copyright wanthings.com
 * @author lizf <lizaifang@gmail.com>
 * @version 0.1
 */
//namespace YiiWxYun;
class YiiWxYun extends CComponent
{
    public $errno;
    public $errmsg;
    public $debug = false;// debug flags
    public $token;
    public $user;
    public $bucket;
    public $options;
    private $yun;

    /**
     * 初始化
     *
     * @param string $user    username of wxyun
     * @param string $token   token of wxyun
     * @param array  $options some config, like debug mode, timeout blablabla
     */
    public function init()
    {
        Yii::import('ext.wxyun.WxYun');
        $this->yun = new WxYun($this->user, $this->token, $this->options);
        //if (isset($options['debug'])) $this->debug = $options['debug'];
    }

    /*
    public static function __callstatic($name, $params)
    {
        if (method_exists($this->yun, $name)) {
            return call_user_func_array(array($this->yun, $name), $params); 
        }
        return parent::__callstatic($name, $params);
    }
    */

    public function __call($name, $params)
    {
        if (method_exists($this->yun, $name)) {
            return call_user_func_array(array($this->yun, $name), $params); 
        }
        return parent::__call($name, $params);
    }
}
